<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
  <style>
    .bg{
      position: fixed;
      left:0;
      right:0;
      top:0;
      bottom: 0;
      background-color: rgba(30,30,30,.3);
    }
    .box{
      width:500px;
      height:500px;
      border:1px solid #ccc;
      position: absolute;
      left:50%;
      margin-left:-250px;
      top:50px;
      background-color: #fff;
    }
    .box2{
      width:200px;
      height:200px;
      background-color: rgb(226, 34, 34);
    }
  </style>
</head>
<body>
  <div id="box">
    <button @click="change">显示</button>
    <div class="bg" @click.self="hide" v-show="show">
      
      <!-- <div class="box" @click.stop></div> -->
      <div class="box"></div>
    </div>
  </div>

  <script>


    let vm = new Vue({
      el:"#box",
      data:{  
        msg:"msg",
        show:false
      },
      methods:{
        change(){
          this.show = true;
        },
        hide(){
          this.show = false;
        }
      }
    });

  
    console.log(vm);
  </script>
</body>
</html>